package com.yun.datastructure.tree.binarysearchtree.leetcode;

import com.yun.datastructure.tree.binarytree.domain.TreeNode;

public class Leetcode700 {
    public TreeNode searchBST(TreeNode root, int val) {
        TreeNode node=root;
        while (node!=null){
            if(val<node.val){
                node=node.left;
            }else if(node.val<val){
                node=node.right;
            }else {
                return node;
            }
        }
        return null;
    }
}
